#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int minimumRecolors(string blocks, int k) {
        int n = blocks.size();
        int sum = 0;
        for (int i = 0; i < k; i++)
        {
            if (blocks[i] == 'W')
                sum++;
        }
        int cur = sum;
        for (int i = k; i < n; i++)
        {
            if (blocks[i - k] == 'W') cur--;
            if (blocks[i] == 'W') cur++;
            sum = min(sum, cur);
        }
        return sum;
    }
};